package com.nfit.shopadmin.service.impl;

import com.nfit.shopadmin.mapper.ProductSkuMapper;
import com.nfit.shopadmin.service.ProductSkuService;
import com.nfit.shopmodel.entity.product.ProductSku;
import com.nfit.shopmodel.vo.h5.indexCarouselVo;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * ClassName:ProductSkuServiceImpl
 * Package:com.nfit.shopadmin.service.impl
 * Description
 *
 * @Author L
 * @Create 2024/12/18 15:24
 */
@Schema(description = "移动端商品sku业务处理")
@Service
public class ProductSkuServiceImpl implements ProductSkuService {

    @Autowired
    private ProductSkuMapper productSkuMapper;

    /**
     *查询商品图片
     */
    @Override
    public List<indexCarouselVo> getImage() {
        //创建list集合返回最终数据
        List<indexCarouselVo> list = new ArrayList<>();

        List<ProductSku> productSkuList = productSkuMapper.getImage();

        productSkuList.stream().forEach(productSku -> {
            indexCarouselVo vo = new indexCarouselVo();
            vo.setId(productSku.getId()); // 注意：这里假设 ProductSku 有一个 getId() 方法，但您的代码中并未显示
            vo.setProductId(productSku.getProductId());
            vo.setThumbImg(productSku.getThumbImg());
            vo.setStatus(productSku.getStatus());
            list.add(vo);
        });
        return list;
    }
}
